package cn.neusoft.edu.his.demo.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import cn.neusoft.edu.his.demo.po.DoctorWork;
import cn.neusoft.edu.his.demo.po.WorkPlan;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

@Mapper
public interface WorkPlanMapper extends BaseMapper<WorkPlan> {
	@Select("select DATE_FORMAT(day, '%Y-%m-%d') as day,weekday,status,create_by from work_plan where year(day)=${year} and month(day)=${month} and day(day)=${day}")
	WorkPlan selectByDay(@Param("year") int year, @Param("month") int month,
			@Param("day") int day);

	@Update("update work_plan set status=${status} where year(day)=${year} and month(day)=${month} and day(day)=${day}")
	int updateByDay(@Param("year") int year, @Param("month") int month,
			@Param("day") int day, @Param("status") int status);

	@Select("select dw.* from doctor_work dw,work_plan wp where dw.day=DATE_FORMAT(wp.day, '%Y-%m-%d') and wp.status=1 and dw.day in (${week})")
	List<DoctorWork> getWorkPlanByWeek(String week);
}
